import Vue from 'vue'
import Vuex from 'vuex'
import {personalLnformation} from '../api/api'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    showUser:true,
    userInfo:{},
    num:'',
    login:false
  },
  mutations: {
    change(state,payload){
      state.showUser = false
      state.userInfo = payload.userInfo
      state.num = payload.userInfo.roles.length
    },
  //  退出
    changeExit(state){
      state.showUser = true;
      state.userInfo = {}
    },
  //  模态框
    changLogin(state,payload){
      state.login = payload
    }
  },
  actions: {
    changeUser(context){
      personalLnformation().then(res=>{
        if(res.code == 0){
          context.commit('change',res)
        }
      })
    }
  },
  modules: {
  }
})
